package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserUnbindPhoneRequest extends Request{

	private static final long serialVersionUID = -4855893653103123434L;

	private int userId;
	
	private String phone;
	
	public UserUnbindPhoneRequest() {
		
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.phone = requestInfo.getParameter(ApiUrlParamEnum.phone.getParamName(), "");
		if (userId < 0) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if (!StringUtil.isMobilePhone(phone)) {
			throw new RequestIllegalException("手机格式有误");
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
}
